﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection sqlcon = new SqlConnection();
        sqlcon.ConnectionString = ConfigurationManager.ConnectionStrings["SqlConnectionString"].ConnectionString;
        sqlcon.Open();

        SqlCommand sqlcmd = new SqlCommand("select * from CODE_REGION ", sqlcon);

        //Label1.Text = sqlcmd.ExecuteScalar().ToString() ;

        SqlDataReader reader = sqlcmd.ExecuteReader(CommandBehavior.CloseConnection);

        if (reader.Read())
        { 

        Label1.Text = reader["NAME"].ToString();}

       // Label1.Text = reader.GetSqlChars(1).ToString() ;
         reader.Close();
        
        SqlDataAdapter sqlsda = new SqlDataAdapter("select * from CODE_REGION ", sqlcon);

        DataSet ds = new DataSet();
        sqlsda.Fill(ds,"dat");


        GridView1.DataSource=ds.Tables["dat"];
        GridView1.DataBind();

    }
}
